package com.andy.qhb.controller.game;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.andy.qhb.base.RespVO;
import com.andy.qhb.controller.GameController;
import com.andy.qhb.game.GameUser;
import com.andy.qhb.game.Global;
import com.andy.qhb.game.QhbGame;
import com.andy.qhb.game.Room;
import com.andy.qhb.utils.JsonUtils;
import com.andy.qhb.vo.ShowMsg;
import com.google.common.collect.Maps;

@Controller
@RequestMapping(value="game/api")
public class Api125Controller extends GameController{
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	/**
	 * 红包状态
	 * @param session
	 * @param data
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value="125")
	public RespVO action(HttpSession session,String data) throws Exception{
		GameUser user = getUser(session);
		Map<String, Object> reqData = JsonUtils.json2Map(data);
		Integer packId = MapUtils.getInteger(reqData, "packId");
		
		QhbGame game = Global.getGame(packId);
		
		Map<String,Object> resp = Maps.newHashMap();
		resp.put("pid", game.getId());
		resp.put("isEnd", game.isEnd());
		resp.put("cname", game.creater().getNickName());
		
		return RespVO.createSuccessJsonResonse(resp);
		
	}
	
	
}